package com.sun.sundemo.controller;

import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhangquanwei
 * @version 1.0
 * @since 2025-01-24 11:30
 */
@RestController
@RequestMapping("/mail")
public class MailController {
    @Resource
    private JavaMailSender jms;
    @Value("${spring.mail.username}")
    private String from;
    @RequestMapping("/send")
    public String sendMail() {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(from);
        message.setTo("quanwei.zhang@sunrate.com");
        message.setSubject("测试邮件");
        message.setText("测试邮件内容");
        jms.send(message);
        return "send mail success";
    }
}
